import time

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

# 创建浏览器驱动对象
browser = webdriver.Chrome()

# 创建等待操作对象
wait_ob = WebDriverWait(browser, 10)

# 加载url
browser.get("http://jd.com")

# 等待条件到来
search_input = wait_ob.until(EC.presence_of_element_located((By.ID, 'key')))

print(search_input)

# 输入内容
search_input.send_keys("Mac Pro")

# 延时等待以便于观看
time.sleep(3)

# 退出
browser.quit()
